class PrimaryReplicaRouter:
    def db_for_read(self, model, **hints):
        """
        读请求路由到从库
        """
        return 'slave1'

    def db_for_write(self, model, **hints):
        """
        写请求路由到主库
        """
        return 'default'

    def allow_relation(self, obj1, obj2, **hints):
        """
        允许所有关系
        """
        return True

    def allow_migrate(self, db, app_label, model_name=None, **hints):
        """
        所有迁移都在主库上执行
        """
        return db == 'default'
